﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tb_HeaderReport_TBDP
/// </summary>
public class cls_tb_HeaderReport_TBDP
{
	public cls_tb_HeaderReport_TBDP()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    #region Select
    public DataTable Select_byMaCN(string F_MACN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];

        para[0] = new SqlParameter("@F_MACN", F_MACN);

        try
        {
            dt = connect.GetSelectCommand("tb_HeaderReport_TBDP_Select_byMaCN", para);
        }
        catch { }
        return dt;
    }
    public string GetManager_byMaCN(string F_MACN)
    {
        string rs = "";
        DataTable dt = new DataTable();
        dt = Select_byMaCN(F_MACN);
        if (dt.Rows.Count > 0)
        {
            rs = dt.Rows[0]["Manager"].ToString();
        }
        return rs;
    }
    #endregion

    #region Insert
    public string Insert(string F_MACN, string HeadOffice_display, string HeadOfficeAddress_display, string BranchType_display, string BranchAddress_display, string PhoneType_display, string PhoneNumber_display, string Fax_display, string CenterName_display, string Manager)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[10];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        para[1] = new SqlParameter("@HeadOffice_display", HeadOffice_display);
        para[2] = new SqlParameter("@HeadOfficeAddress_display", HeadOfficeAddress_display);
        para[3] = new SqlParameter("@BranchType_display", BranchType_display);
        para[4] = new SqlParameter("@BranchAddress_display", BranchAddress_display);
        para[5] = new SqlParameter("@PhoneType_display", PhoneType_display);
        para[6] = new SqlParameter("@PhoneNumber_display", PhoneNumber_display);
        para[7] = new SqlParameter("@Fax_display", Fax_display);
        para[8] = new SqlParameter("@CenterName_display", CenterName_display);
        para[9] = new SqlParameter("@Manager", Manager);

        try
        {
            connect.ExecuteQuery("tb_HeaderReport_TBDP_Insert", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion

    #region Update
    public string Update(string F_MACN, string HeadOffice_display, string HeadOfficeAddress_display, string BranchType_display, string BranchAddress_display, string PhoneType_display, string PhoneNumber_display, string Fax_display, string CenterName_display, string Manager)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[10];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        para[1] = new SqlParameter("@HeadOffice_display", HeadOffice_display);
        para[2] = new SqlParameter("@HeadOfficeAddress_display", HeadOfficeAddress_display);
        para[3] = new SqlParameter("@BranchType_display", BranchType_display);
        para[4] = new SqlParameter("@BranchAddress_display", BranchAddress_display);
        para[5] = new SqlParameter("@PhoneType_display", PhoneType_display);
        para[6] = new SqlParameter("@PhoneNumber_display", PhoneNumber_display);
        para[7] = new SqlParameter("@Fax_display", Fax_display);
        para[8] = new SqlParameter("@CenterName_display", CenterName_display);
        para[9] = new SqlParameter("@Manager", Manager);

        try
        {
            connect.ExecuteQuery("tb_HeaderReport_TBDP_Update", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion

    #region Delete
    public string Delete(string F_MACN)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);

        try
        {
            connect.ExecuteQuery("tb_HeaderReport_TBDP_Detele", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion
}